const todos = (state = [], action) => {
	switch (action.type) {
		case 'ADD_TODO':
			return [
				...state,
				{
					text: action.text,
					id: action.id,
					completed: false,
				}
			];
		case 'COMPLETE_TODO':
			return state.map(todo =>{
			  return	(todo.id === action.id) ? {...todo,completed:!todo.completed} : todo
			})
		case 'CLEAR_TODOS':
			return []
		default :
			return state;
	}
}

export default todos;